home *** CD-ROM | disk | FTP | other *** search
/ Aminet 40 / Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso / Aminet / misc / emu / TDMouse-1.1os.lha / TDMouse / MouseTest.c < prev    next >
C/C++ Source or Header  |  2000-10-06  |  4KB  |  144 lines

  1. /*
  2. // ##########################################################################
  3. // ####                                                                  ####
  4. // ####           TDMouse - A serial mouse driver for the Amiga          ####
  5. // ####          ===============================================         ####
  6. // ####                                                                  ####
  7. // #### MouseTest.c                                                      ####
  8. // ####                                                                  ####
  9. // #### Version 0.80  --  October 06, 2000                               ####
  10. // ####                                                                  ####
  11. // #### Copyright (C) 1995  Thomas Dreibholz                             ####
  12. // ####                     Molbachweg 7                                 ####
  13. // ####                     51674 Wiehl/Germany                          ####
  14. // ####                     EMail: Dreibholz@bigfoot.com                 ####
  15. // ####                     WWW:   http://www.bigfoot.com/~dreibholz     ####
  16. // ####                                                                  ####
  17. // ##########################################################################
  18. */
  19. /***************************************************************************
  20.  *                                                                         *
  21.  *   This program is free software; you can redistribute it and/or modify  *
  22.  *   it under the terms of the GNU General Public License as published by  *
  23.  *   the Free Software Foundation; either version 2 of the License, or     *
  24.  *   (at your option) any later version.                                   *
  25.  *                                                                         *
  26.  ***************************************************************************/
  27.  
  28.  
  29. #define EMPTY "                            "
  30.  
  31. struct IntuitionBase *IntuitionBase;
  32. struct GfxBase       *GfxBase;
  33.  
  34. struct NewWindow nw=
  35. {
  36.  160,100,320,85,
  37.  0,1,
  38.  MOUSEMOVE|MOUSEBUTTONS|CLOSEWINDOW,
  39.  RMBTRAP|REPORTMOUSE|WINDOWDEPTH|WINDOWCLOSE|WINDOWDRAG|ACTIVATE|GIMMEZEROZERO,
  40.  0L,0L,"MouseTest!",0L,0L,
  41.  100,20,640,256,
  42.  WBENCHSCREEN
  43. };
  44.  
  45. struct Window   *win;
  46. struct RastPort *rp;
  47.  
  48. void Print();
  49. void PrintXY();
  50. void PrintButtons();
  51.  
  52. main()
  53. {
  54.  REGISTER BOOL  ende;
  55.  REGISTER WORD  x,y,b;
  56.  REGISTER ULONG Class;
  57.  REGISTER UWORD Code;
  58.  REGISTER UWORD Qualifier;
  59.  register struct IntuiMessage *msg;
  60.  
  61.  IntuitionBase=OpenLibrary("intuition.library",0L);
  62.  GfxBase=OpenLibrary("graphics.library",0L);
  63.  if((IntuitionBase==NULL)||(GfxBase==NULL)) exit(0);
  64.  
  65.  win=OpenWindow(&nw);
  66.  if(win!=NULL)
  67.   {
  68.    rp=win->RPort;
  69.    Print(15,10,"Maus bewegen!");
  70.    Print(15,25,"Maustasten:");
  71.  
  72.    ende=FALSE;
  73.    do
  74.     {
  75.      b=0;
  76.      WaitPort(win->UserPort);
  77.      msg=GetMsg(win->UserPort);
  78.      Class=msg->Class;
  79.      Code=msg->Code;
  80.      Qualifier=msg->Qualifier;
  81.      x=msg->MouseX;
  82.      y=msg->MouseY;
  83.      ReplyMsg(msg);
  84.      switch(Class)
  85.       {
  86.        case MOUSEMOVE:
  87.          PrintXY(x,y);
  88.          PrintButtons(Qualifier);
  89.         break;
  90.        case MOUSEBUTTONS:
  91.          PrintXY(x,y);
  92.          PrintButtons(Qualifier);
  93.         break;
  94.        case CLOSEWINDOW:
  95.          ende=TRUE;
  96.         break;
  97.       }
  98.     }
  99.    while(ende==FALSE);
  100.  
  101.    CloseWindow(win);
  102.   }
  103.  else
  104.    puts("FEHLER: Kann Fenster nicht öffnen!");
  105.  
  106.  CloseLibrary(GfxBase);
  107.  CloseLibrary(IntuitionBase);
  108.  exit(0);
  109. }
  110.  
  111. void Print(x,y,text)
  112.  UWORD  x,y;
  113.  UBYTE *text;
  114. {
  115.  Move(rp,x,y);
  116.  Text(rp,text,strlen(text));
  117. }
  118.  
  119. void PrintXY(x,y)
  120.  WORD x,y;
  121. {
  122.  UBYTE buffer[40];
  123.  
  124.  sprintf(&buffer,"X=%4d  Y=%4ld",x,y);
  125.  Print(15,10,&buffer);
  126. }
  127.  
  128. void PrintButtons(qualifier)
  129.  UWORD qualifier;
  130. {
  131.  REGISTER BYTE l,r,m;
  132.  
  133.  l=r=m=0;
  134.  
  135.  if(qualifier & IEQUALIFIER_LEFTBUTTON) l=1;
  136.  if(qualifier & IEQUALIFIER_RBUTTON) r=1;
  137.  if(qualifier & IEQUALIFIER_MIDBUTTON) m=1;
  138.  
  139.  if(l) Print(130,25,"Linke Maustaste");    else Print(130,25,EMPTY);
  140.  if(m) Print(130,40,"Mittlere Maustaste"); else Print(130,40,EMPTY);
  141.  if(r) Print(130,55,"Rechte Maustaste");   else Print(130,55,EMPTY);
  142. }
  143.  
  144.